package com.dingding.core.special.dao.impl;

import javax.annotation.Resource;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.dingding.common.core.base.daox.IBaseDaoX;
import com.dingding.common.core.base.daox.ISQLBaseDao;
import com.dingding.common.core.beans.special.Specialuserlogin;
import com.dingding.core.special.dao.ISpecialUserInfoDao;
import com.dingding.core.special.sql.SpecialUserInfoSQL;

/**
 * 
 * @ClassName: SpecialUserAccountDaoImpl 
 * @Description: 专车用户账户DAO实现类
 * @author YHQ
 * @date 2016年12月28日 上午9:51:25
 * @since V2.6.3
 * 
 */
@Component("specialUserDao")
public class SpecialUserInfoDaoImpl implements ISpecialUserInfoDao{

	private Logger log = Logger.getLogger(this.getClass());
	
	@Resource(name = "baseDaoX")
	private IBaseDaoX baseDaoX;
	
	@Resource(name = "SQLBaseDao")
	private ISQLBaseDao sqlBaseDao;
	
	/**
	 * 
	 * @Title: getSpecialUserLogin 
	 * @Description: 根据用户Id获取专车用户登录信息
	 * @param userId 用户Id
	 * @author YHQ 
	 * @since V2.6.3
	 * @return Specialuserlogin    返回类型
	 * 
	 */
	@Override
	@Transactional(readOnly = true)
	public Specialuserlogin getSpecialUserLogin(String userId) {
		
		try {
			return baseDaoX.getById(userId, Specialuserlogin.class);
		} catch (Exception e) {
			log.error("根据用户Id获取专车用户登录信息时出现异常   类： " + this.getClass() + " getSpecialUserLogin()", e);
		}
		
		return null;
	}

	/**
	 * 
	 * @Title: updateSpecialUserLogin 
	 * @Description: 修改专车用户登录信息 
	 * @param specialuserlogin 专车用户登录信息
	 * @author YHQ 
	 * @since V2.6.3
	 * @return boolean    返回类型
	 * 
	 */
	@Override
	@Transactional(propagation = Propagation.REQUIRED)
	public boolean updateSpecialUserLogin(Specialuserlogin specialuserlogin) {
		
		try {
			baseDaoX.update(specialuserlogin);
			return true;
		} catch (Exception e) {
			log.error("修改专车用户登录信息时出现异常   类： " + this.getClass() + " updateSpecialUserLogin()", e);
		}
		
		return false;
	}

	/**
	 * 
	 * @Title: resetSpecialDepositNumber 
	 * @Description: 重置专车提现次数
	 * @author YHQ 
	 * @since V2.6.3
	 * @return boolean    返回类型
	 * 
	 */
	@Override
	@Transactional(propagation = Propagation.REQUIRED)
	public boolean resetSpecialDepositNumber() {
		
		try {
			sqlBaseDao.updateSqLRow(SpecialUserInfoSQL.RESET_SPECIAL_DEPOSIT_NUMBER);
			return true;
		} catch (Exception e) {
			log.error("重置专车提现次数时出现异常   类：" + this.getClass() + " resetSpecialDepositNumber()", e);
		}
		
		return false;
	}

}
